/**
 * ZbiorWielobokow.cpp
 *
 * Version: $Id: ZbiorWielobokow.cpp 78 2012-01-07 11:54:28Z s8376@pjwstk.edu.pl $
 */
#include <iostream>
#include "ZbiorWielobokow.h"

using namespace std;

ZbiorWielobokow::ZbiorWielobokow(int value)
{
    _collection = new Wielobok*[value];
    _collectionSize = value;
}
ZbiorWielobokow::ZbiorWielobokow(const ZbiorWielobokow& ob)
{
    _collectionSize = ob._collectionSize;
    _collection = new Wielobok*[_collectionSize];

    for (int i = 0; i < _collectionSize; i++) {
        _collection[i] = ob._collection[i];
    }
}
ZbiorWielobokow::~ZbiorWielobokow()
{
    for (int i = 0; i < _collectionSize; i++) {
        delete _collection[i];
    }
    delete[] _collection;
    _collection = 0;
}
bool ZbiorWielobokow::show()
{
    for (int i = 0; i < _collectionSize; i++) {
        _collection[i]->show();
    }
}
void ZbiorWielobokow::insert(const Wielobok& ob, int index)
{
    _collection[(index - 1)] = new Wielobok(ob);
}
void ZbiorWielobokow::deleteObject(int index)
{
    delete _collection[(index - 1)];
}
Wielobok ZbiorWielobokow::get_max()
{
    bool foundFlag = false;
    double maxValue = 0;
    int maxIndex = 0;

    for (int i = 0; i < _collectionSize; i++) {
        if (_collection[i]->getParimeter() > maxValue) {
            maxValue = _collection[i]->getParimeter();

cout << _collection[i]->getParimeter() << endl;


            maxIndex = i;
            foundFlag = true;
        }
    }

    if (!foundFlag) {
// FIXME error
    }

    return *_collection[maxIndex];
}
